package Server;

import Server.provider.ServiceProvider;
import Server.server.RpcServer;
import Server.server.impl.NettyRPCServer;
import Server.server.impl.SimpleRPCServer;
import Server.server.impl.ThreadPoolRPCServer;
import common.service.impl.UserServiceImpl;

import java.util.concurrent.*;

public class TestServer {
    public static void main(String[] args) {
        // 创建服务实现类
        UserServiceImpl userService = new UserServiceImpl();
        // 实例化服务注册中心，管理所有可供客户端调用的服务
        ServiceProvider serviceProvider = new ServiceProvider("127.0.0.1", 8899);
        // 注册服务
        serviceProvider.provideServiceInterface(userService, true);

        // 创建线程池参数
//        int corePoolSize = Runtime.getRuntime().availableProcessors(); // 核心线程数
//        int maximumPoolSize = 1000; // 最大线程数
//        long keepAliveTime = 60; // 线程空闲时间
//        TimeUnit unit = TimeUnit.SECONDS; // 时间单位
//        BlockingDeque<Runnable> workQueue = new LinkedBlockingDeque<>(100); // 任务队列

        // 实例化RPC服务端

        //RpcServer rpcServer = new SimpleRPCServer(serviceProvider);
        //RpcServer rpcServer = new ThreadPoolRPCServer(serviceProvider, corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue);

        RpcServer rpcServer = new NettyRPCServer(serviceProvider);
        rpcServer.start(8899);
    }
}